﻿/*=======================================================================
	TASK 7:                                                      {Arrays}
	Sorting an array means to arrange its elements in increasing order.
    Write a program to sort an array. Use the "selection sort" algorithm:
    Find the smallest element, move it at the first position, find the 
    smallest from the rest, move it at the second position, etc. 
=======================================================================*/

using System;

class SelectionSortAlgoritnm
{
    static void Main()
    {
        int[] arr = { -60,4, -5, 1, 2,-6 ,-10,0,5};

        int min ;
        int exchangeValues;

        for (int i = 0; i < arr.Length; i++)
        {
            min = i;

            for (int j = i + 1; j < arr.Length; j++)
            {
                if (arr[j] < arr[min])
                {
                    min = j;
                }
            }

            exchangeValues = arr[i];
            arr[i] = arr[min];
            arr[min] = exchangeValues;
        }

        for (int n = 0; n < arr.Length; n++)
        {
            Console.Write(arr[n] + " ");
        }
    }
}
